import request from "@/utils/request";

/**
 *
 * 查询分页数据
 * @param {*} params
 * @returns
 */
export function pages(params) {
  return request({
    url: process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/thirdService/queryPages",
    method: "get",
    params: params
  });
}

/**
 * 保存事项数据
 * @param {*} data
 */
export function saveOrUpdate(data) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH + "/yxpz/thirdService/saveOrUpdate",
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    },
    data: data
  });
}

/**
 * 根据serviceOid查询数据
 * @param {*} serviceOid
 */
export function queryByServiceOid(serviceOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdService/queryByServiceOid",
    method: "get",
    params: {
      serviceOid
    }
  });
}

/**
 * 切换状态
 * @param {*} serviceOid
 * @param {*} stateFlag
 */
export function tiggerStateByServiceOid(serviceOid, stateFlag) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdService/tiggerStateByServiceOid",
    method: "get",
    params: {
      serviceOid,
      state: stateFlag
    }
  });
}

/**
 * 删除事项数据
 * @param {*} serviceOid
 * @returns
 */
export function deleteByServiceOid(serviceOid) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/thirdService/deleteByServiceOid/${serviceOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}

/**
 * 通过serviceCode 查询是否存在事项，true 存在 false 不存在
 * @param {*} serviceCode
 */
export function checkExistByServiceCode(serviceCode) {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      "/yxpz/thirdService/checkExistByServiceCode",
    method: "get",
    params: {
      serviceCode
    }
  });
}

/**
 * 下载模板的路径
 * @returns
 */
export function excelExportService() {
  return (
    process.env.VUE_APP_BASE_API +
    process.env.VUE_APP_KSTB_ROUTE_PATH +
    `/yxpz/thirdService/excelExportService`
  );
}

/**
 * 导入excel事项数据
 */
export function importExcel(insertPatter) {
  return (
    process.env.VUE_APP_BASE_API +
    process.env.VUE_APP_KSTB_ROUTE_PATH +
    `/yxpz/thirdService/importExcel/${insertPatter}`
  );
}

/**
 * 校验事项数据是否被清单关联使用
 * @param {*} serviceOid
 */
export function checkExistHasRelHdl(serviceOid = "") {
  return request({
    url:
      process.env.VUE_APP_KSTB_ROUTE_PATH +
      `/yxpz/thirdService/checkExistHasRelHdl/${serviceOid}`,
    method: "post",
    headers: {
      "Content-Type": "application/json;charset=UTF-8"
    }
  });
}
